<template>
  <div class="_wz_cent_main _wz_trainList">
    <Card dis-hover :bordered="true" style="margin:0 0 10px;">
      <p slot="title">搜索</p>
      <Form :model="formDataSearch" label-position="right" :label-width="100" inline>
        <FormItem label="从业人员">
          <i-input type="text" v-model="formDataSearch.driverName" placeholder="从业人员" clearable />
        </FormItem>
        <FormItem label="驾乘车辆">
          <i-input type="text" v-model="formDataSearch.driverVehiclePlate" placeholder="驾乘车辆" clearable />
        </FormItem>
        <FormItem label="培训进度">
          <i-select v-model="formDataSearch.finishState" filterable placeholder="培训进度" clearable>
            <Option value="0">未开始</Option>
            <Option value="2">进行中</Option>
            <Option value="1">已完成</Option>
          </i-select>
        </FormItem>
        <FormItem>
          <Button type="primary" @click="searchSubmit">搜索</Button>
        </FormItem>

      </Form>
    </Card>
    <div>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </div>
    <Spin size="large" fix v-if="spinShow"></Spin>

  </div>
</template>
<script>
  import wzTbale from "../../../components/table/table";

  export default {
    components: {
      wzTbale,//列表
    },
    props:["selectData"],
    data() {
      return {
        formDataSearch:{trainPlanUuid:this.selectData.uuid},
        spinShow:false,//本页加载
        tableData: {
          url: this.apiUrl.educateTrainPlanTrainCourseStudentPlanList,//请求地址
          method: 'post',//请求方式
          where: {trainPlanUuid:this.selectData.uuid},//搜索条件
          height: 'auto',//表格高度 auto
          page: false,//分页是否使用
          columns: [//表头数据
            {type: 'index', width: 70, align: 'center', title: '序号'},
            {title: '从业人员', key: 'driverName', minWidth: 100},
            {title: '从业类型', key: 'driverTypeName', minWidth: 100},
            {title: '驾乘车辆', key: 'driverVehicleNo', minWidth: 100},
            {title: '身份证号', key: 'driverIdentifyNum', minWidth: 160},
            {title: '联系电话', key: 'driverPhone', minWidth: 120},
            {
              title: '培训情况', key: '', minWidth: 130, render: (h, params) => {
                if (params.row.trainCourseStudentPlanFinish == 0) {
                  return h('Tag', {props: {type: 'dot',color: 'error'}}, '未开始')
                } else if (params.row.trainCourseStudentPlanFinish == 1) {
                  return h('Tag', {props: {type: 'dot',color: 'success'}}, '已完成')
                } else{
                  return h('Tag', {props: {type: 'dot',color: 'warning'}}, '进行中')
                }
              }
            },
            {
              title: '培训时长', key: 'trainCourseStudentPlanTotalDuration', minWidth: 140, render: (h, params) => {
                return h('span', params.row.trainCourseStudentPlanLearnDuration + "/"+params.row.trainCourseStudentPlanTotalDuration + "分钟");
              }
            },
            {
              title: '培训进度', key: '', minWidth: 100, render: (h, params) => {
                return h('span', params.row.trainCourseStudentPlanFinishedNumber + "/" + params.row.trainCourseStudentPlanMaterialNumber);
              }
            },
            {
              title: '随堂测验', key: '', minWidth: 130, render: (h, params) => {
                if (params.row.trainCourseStudentPlanExam == 1) {
                  if (params.row.trainCourseStudentPlanExamState == 0) {
                    return h('Tag', {props: {type: 'dot',color: 'error'}}, '未开始')
                  } else if (params.row.trainCourseStudentPlanExamState == 1) {
                    return h('Tag', {props: {type: 'dot',color: 'success'}}, '及格')
                  } else{
                    return h('Tag', {props: {type: 'dot',color: 'warning'}}, '不及格')
                  }
                } else{
                  return h('span', '--')
                }
              }
            },
          ],
          format: {//返回数据格式
            list: ['data'],//数据list
          },
        },
      }
    },
    computed: {//计算属性

    },
    beforeCreate() {//beforeCreate创建前状态

    },
    created() {//created创建完毕状态

    },
    beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

    },
    mounted() {//mounted 挂载结束状态

    },
    methods: {//执行的方法
      searchSubmit() {//搜索
        this.tableData.where = JSON.parse(JSON.stringify(this.formDataSearch));
        this.$refs.wzTbale.tableLoadData(true);
      },
    },
    watch: {//监听

    },
    beforeUpdate() {//beforeUpdate 更新前状态

    },
    updated() {//updated 更新完成状态

    },
    beforeDestroy() {//beforeDestroy 销毁前状态

    },
    destroyed() {//destroyed 销毁完成状态

    }
  }
</script>
<style lang="less">
  ._wz_trainList{
    width: 100%;
    height: 100%;
  }

</style>
